package org.example.springaop;

import org.aspectj.lang.JoinPoint;
import org.slf4j.Logger;
import org.slf4j.Marker;

class AspectLogger implements Logger {

    private final String signature;
    private final Logger log;

    public AspectLogger(Logger log, JoinPoint joinPoint) {
        this.log = log;
        this.signature = getSignature(joinPoint);
    }

    private String getSignature(JoinPoint joinPoint) {
        return joinPoint.getSignature().getDeclaringType().getSimpleName() + "." +
                joinPoint.getSignature().getName();
    }

    private String getMessage(String message) {
        return String.format("#aspect# %s - %s", signature, message);
    }

    @Override
    public String getName() {
        return log.getName();
    }

    @Override
    public boolean isTraceEnabled() {
        return log.isTraceEnabled();
    }

    @Override
    public void trace(String s) {
        log.trace(getMessage(s));
    }

    @Override
    public void trace(String s, Object o) {
        log.trace(getMessage(s), o);
    }

    @Override
    public void trace(String s, Object o, Object o1) {
        log.trace(getMessage(s), o, o1);
    }

    @Override
    public void trace(String s, Object... objects) {
        log.trace(getMessage(s), objects);
    }

    @Override
    public void trace(String s, Throwable throwable) {
        log.trace(getMessage(s), throwable);
    }

    @Override
    public boolean isTraceEnabled(Marker marker) {
        return log.isTraceEnabled(marker);
    }

    @Override
    public void trace(Marker marker, String s) {
        log.trace(marker, getMessage(s));
    }

    @Override
    public void trace(Marker marker, String s, Object o) {
        log.trace(marker, getMessage(s), o);
    }

    @Override
    public void trace(Marker marker, String s, Object o, Object o1) {
        log.trace(marker, getMessage(s), o, o1);
    }

    @Override
    public void trace(Marker marker, String s, Object... objects) {
        log.trace(marker, getMessage(s), objects);
    }

    @Override
    public void trace(Marker marker, String s, Throwable throwable) {
        log.trace(marker, getMessage(s), throwable);
    }

    @Override
    public boolean isDebugEnabled() {
        return log.isDebugEnabled();
    }

    @Override
    public void debug(String s) {
        log.debug(getMessage(s));
    }

    @Override
    public void debug(String s, Object o) {
        log.debug(getMessage(s), o);
    }

    @Override
    public void debug(String s, Object o, Object o1) {
        log.debug(getMessage(s), o, o1);
    }

    @Override
    public void debug(String s, Object... objects) {
        log.debug(getMessage(s), objects);
    }

    @Override
    public void debug(String s, Throwable throwable) {
        log.debug(getMessage(s), throwable);
    }

    @Override
    public boolean isDebugEnabled(Marker marker) {
        return log.isDebugEnabled(marker);
    }

    @Override
    public void debug(Marker marker, String s) {
        log.debug(marker, getMessage(s));
    }

    @Override
    public void debug(Marker marker, String s, Object o) {
        log.debug(marker, getMessage(s), o);
    }

    @Override
    public void debug(Marker marker, String s, Object o, Object o1) {
        log.debug(marker, getMessage(s), o, o1);
    }

    @Override
    public void debug(Marker marker, String s, Object... objects) {
        log.debug(marker, getMessage(s), objects);
    }

    @Override
    public void debug(Marker marker, String s, Throwable throwable) {
        log.debug(marker, getMessage(s), throwable);
    }

    @Override
    public boolean isInfoEnabled() {
        return log.isInfoEnabled();
    }

    @Override
    public void info(String s) {
        log.info(getMessage(s));
    }

    @Override
    public void info(String s, Object o) {
        log.info(getMessage(s), o);
    }

    @Override
    public void info(String s, Object o, Object o1) {
        log.info(getMessage(s), o, o1);
    }

    @Override
    public void info(String s, Object... objects) {
        log.info(getMessage(s), objects);
    }

    @Override
    public void info(String s, Throwable throwable) {
        log.info(getMessage(s), throwable);
    }

    @Override
    public boolean isInfoEnabled(Marker marker) {
        return log.isInfoEnabled(marker);
    }

    @Override
    public void info(Marker marker, String s) {
        log.info(marker, getMessage(s));
    }

    @Override
    public void info(Marker marker, String s, Object o) {
        log.info(marker, getMessage(s), o);
    }

    @Override
    public void info(Marker marker, String s, Object o, Object o1) {
        log.info(marker, getMessage(s), o, o1);
    }

    @Override
    public void info(Marker marker, String s, Object... objects) {
        log.info(marker, getMessage(s), objects);
    }

    @Override
    public void info(Marker marker, String s, Throwable throwable) {
        log.info(marker, getMessage(s), throwable);
    }

    @Override
    public boolean isWarnEnabled() {
        return log.isWarnEnabled();
    }

    @Override
    public void warn(String s) {
        log.warn(getMessage(s));
    }

    @Override
    public void warn(String s, Object o) {
        log.warn(getMessage(s), o);
    }

    @Override
    public void warn(String s, Object... objects) {
        log.warn(getMessage(s), objects);
    }

    @Override
    public void warn(String s, Object o, Object o1) {
        log.warn(getMessage(s), o, o1);
    }

    @Override
    public void warn(String s, Throwable throwable) {
        log.warn(getMessage(s), throwable);
    }

    @Override
    public boolean isWarnEnabled(Marker marker) {
        log.isWarnEnabled(marker);
        return log.isWarnEnabled(marker);
    }

    @Override
    public void warn(Marker marker, String s) {
        log.warn(marker, getMessage(s));
    }

    @Override
    public void warn(Marker marker, String s, Object o) {
        log.warn(marker, getMessage(s), o);
    }

    @Override
    public void warn(Marker marker, String s, Object o, Object o1) {
        log.warn(marker, getMessage(s), o, o1);
    }

    @Override
    public void warn(Marker marker, String s, Object... objects) {
        log.warn(marker, getMessage(s), objects);
    }

    @Override
    public void warn(Marker marker, String s, Throwable throwable) {
        log.warn(marker, getMessage(s), throwable);
    }

    @Override
    public boolean isErrorEnabled() {
        return log.isErrorEnabled();
    }

    @Override
    public void error(String s) {
        log.error(getMessage(s));
    }

    @Override
    public void error(String s, Object o) {
        log.error(getMessage(s), o);
    }

    @Override
    public void error(String s, Object o, Object o1) {
        log.error(getMessage(s), o, o1);
    }

    @Override
    public void error(String s, Object... objects) {
        log.error(getMessage(s), objects);
    }

    @Override
    public void error(String s, Throwable throwable) {
        log.error(getMessage(s), throwable);
    }

    @Override
    public boolean isErrorEnabled(Marker marker) {
        return log.isErrorEnabled(marker);
    }

    @Override
    public void error(Marker marker, String s) {
        log.error(marker, getMessage(s));
    }

    @Override
    public void error(Marker marker, String s, Object o) {
        log.error(marker, getMessage(s), o);
    }

    @Override
    public void error(Marker marker, String s, Object o, Object o1) {
        log.error(marker, getMessage(s), o, o1);
    }

    @Override
    public void error(Marker marker, String s, Object... objects) {
        log.error(marker, getMessage(s), objects);
    }

    @Override
    public void error(Marker marker, String s, Throwable throwable) {
        log.error(marker, getMessage(s), throwable);
    }
}
